package com.whj.apidriver.service.impl;

import com.whj.apidriver.remote.ServiceOrderClient;
import com.whj.apidriver.service.OrderService;
import com.whj.internalcommon.constant.IdentityConstant;
import com.whj.internalcommon.dto.ResponseResult;
import com.whj.internalcommon.request.OrderRequest;
import com.whj.serviceorder.entity.OrderInfo;
import org.bouncycastle.asn1.cmp.OOBCertHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: wanghaijun
 * @Date: 2023/2/26 - 02 - 26 - 14:26 
 * @Description: com.whj.apidriver.service.impl
 */

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private ServiceOrderClient serviceOrderClient;

    /**
     * 司机去接乘客
     *
     * @param orderRequest
     * @return
     */
    @Override
    public ResponseResult toPickUpPassenger(OrderRequest orderRequest) {
        return serviceOrderClient.changeStatus(orderRequest);
    }

    /**
     * 司机到达接乘客的位置
     *
     * @param orderRequest
     * @return
     */
    @Override
    public ResponseResult arriveDeparture(OrderRequest orderRequest) {
        return serviceOrderClient.arriveDeparture(orderRequest);
    }

    /**
     * 司机接到乘客
     *
     * @param orderRequest
     * @return
     */
    @Override
    public ResponseResult pickUpPassenger(OrderRequest orderRequest) {
        return serviceOrderClient.pickUpPassenger(orderRequest);
    }

    /**
     * 乘客达到目的地,订单中止
     *
     * @param orderRequest
     * @return
     */
    @Override
    public ResponseResult passengerGetOff(OrderRequest orderRequest) {
        return serviceOrderClient.passengerGetOff(orderRequest);
    }


    /**
     * 乘客取消订单
     *
     * @param orderId 订单id
     * @return
     */
    @Override
    public ResponseResult cancel(Long orderId) {
        serviceOrderClient.cancel(orderId, IdentityConstant.DRIVER_IDENTITY);
        return ResponseResult.success("");
    }

    @Override
    public ResponseResult<OrderInfo> detail(Long orderId) {
        return serviceOrderClient.detail(orderId);
    }

    @Override
    public ResponseResult<OrderInfo> currentOrder(String phone, String driverIdentity) {
        return serviceOrderClient.current(phone,driverIdentity);
    }
}
